package com.ruoyi.life.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.life.domain.ZsCustomerFollow;
import com.ruoyi.life.service.IZsCustomerFollowService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 客户跟进Controller
 *
 * @author cjie
 * @date 2021-08-03
 */
@Api(tags = " 客户跟进")
@RestController
@RequestMapping("/zsCustomerFollow")
public class ZsCustomerFollowController extends BaseController {
    @Autowired
    private IZsCustomerFollowService zsCustomerFollowService;

    /**
     * 查询客户跟进列表
     */
    @ApiOperation(value="查询客户跟进列表", notes="查询客户跟进列表")
    @PreAuthorize(hasPermi = "life:zsCustomerFollow:list")
    @GetMapping("/list")
    public TableDataInfo list(ZsCustomerFollow zsCustomerFollow) {
        startPage();
        List<ZsCustomerFollow> list = zsCustomerFollowService.selectZsCustomerFollowList(zsCustomerFollow);
        return getDataTable(list);
    }

    /**
     * 导出客户跟进列表
     */
    @ApiOperation(value="导出客户跟进列表", notes="导出客户跟进列表")
    @PreAuthorize(hasPermi = "life:zsCustomerFollow:export")
    @Log(title = "客户跟进", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZsCustomerFollow zsCustomerFollow) throws IOException {
        List<ZsCustomerFollow> list = zsCustomerFollowService.selectZsCustomerFollowList(zsCustomerFollow);
        ExcelUtil<ZsCustomerFollow> util = new ExcelUtil<ZsCustomerFollow>(ZsCustomerFollow.class);
        util.exportExcel(response, list, "客户跟进数据");
    }
    /**
     * 获取客户跟进详细信息
     */
    @ApiOperation(value="获取客户跟进详细信息", notes="获取客户跟进详细信息")
    @PreAuthorize(hasPermi = "life:zsCustomerFollow:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(zsCustomerFollowService.selectZsCustomerFollowById(id));
    }

    /**
     * 新增客户跟进
     */
    @ApiOperation(value="新增客户跟进", notes="新增客户跟进")
    @PreAuthorize(hasPermi = "life:zsCustomerFollow:add")
    @Log(title = "客户跟进", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZsCustomerFollow zsCustomerFollow) {
        return toAjax(zsCustomerFollowService.insertZsCustomerFollow(zsCustomerFollow));
    }

    /**
     * 修改客户跟进
     */
    @ApiOperation(value="修改客户跟进", notes="修改客户跟进")
    @PreAuthorize(hasPermi = "life:zsCustomerFollow:edit")
    @Log(title = "客户跟进", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZsCustomerFollow zsCustomerFollow) {
        return toAjax(zsCustomerFollowService.updateZsCustomerFollow(zsCustomerFollow));
    }

    /**
     * 删除客户跟进
     */
    @ApiOperation(value="删除客户跟进", notes="删除客户跟进")
    @ApiImplicitParam(name = "ids", value = "客户跟进ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "life:zsCustomerFollow:remove")
    @Log(title = "客户跟进", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(zsCustomerFollowService.deleteZsCustomerFollowByIds(ids));
    }
}
